package com.ad.pet.app.mall.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ad.pet.R;
import com.ad.pet.common.data.utils.SpUtil;
import com.ad.pet.common.data.utils.glide.GlideUtil;
import com.ad.pet.constant.Constant;
import com.ad.pet.models.remote.home.HomeMall;

import java.util.List;

/**
 * Created by liuyixiang on 2019/9/21.
 */

public class StroeGoodAdapter extends BaseQuickAdapter<HomeMall,BaseViewHolder> {
    public StroeGoodAdapter(@Nullable List<HomeMall> data) {
        super(R.layout.item_shop_good_detail_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeMall item) {
        ImageView ivGood = helper.getView(R.id.iv_good);
        TextView tvTilte = helper.getView(R.id.tv_price);
            boolean end = item.isEnd();
            if (end){
                tvTilte.setVisibility(View.INVISIBLE);
                ivGood.setScaleType(ImageView.ScaleType.CENTER);
                ivGood.setImageResource(R.drawable.look_ic_more);

            }else {
                tvTilte.setVisibility(View.VISIBLE);
                GlideUtil.load(mContext,item.getImage(),ivGood);
                ivGood.setScaleType(ImageView.ScaleType.FIT_XY);
                tvTilte.setText(SpUtil.getInstance().getString(Constant.CURRENCY_LABEL,"US $")+item.getPrice());

            }
    }
}
